using UnityEngine;
using System.Collections;

public class spawn : MonoBehaviour {
	
	public GameObject obj;
	public float delay=1.0f;
	public float lifetime = 99999f;
	private float timer=0.0f;

	// Use this for initialization
	void Start () {
		
		timer = Random.Range (0f,delay*100f)/100f;
	
	}
	
	// Update is called once per frame
	void Update () {
		
		timer+=Time.deltaTime;
		if(timer>delay)
		{
			timer=0f;
			
			GameObject clone;
			clone=Instantiate(obj,transform.position,transform.rotation) as GameObject;
			Destroy (clone,lifetime);
		}
	
	}
}
